import Remilia from "./instance/Remilia.js";
import SaveManager from "../save/SaveManager.js";
import Flandre from "./instance/Flandre.js";

let character_dispatch = {
    all_character_dispatch: [
        Remilia, Flandre
    ], // 这里存放的是所有实装的角色

    get_character_save(id, save) {
        let ret = save.load_data(`character-${id}`);
        if (ret === null) {
            for (let Character of this.all_character_dispatch) {
                if (new Character().id === id) {
                    return new Character();
                }
            }
        } else {
            for (let Character of this.all_character_dispatch) {
                if (new Character().id === id) {
                    let new_character = new Character();
                    // 将保存的数据覆盖到新角色实例上
                    Object.assign(new_character, ret);
                    return new_character;
                }
            }
        }
        return null;
    }
};

export default character_dispatch;